package com.company.lifecycleCallbacks.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;
import java.util.Arrays;

/**
 * @Author: zhaopeng
 * @Date: Created in 11:31 2020/9/29
 * @Modified By:
 */
@Component
public class PostConstructTest implements ApplicationContextAware {

	private ApplicationContext applicationContext;

	public PostConstructTest() {
		System.out.println("构造方法");
	}

	@PostConstruct
	public void populateStudentCache() {
		System.out.println("存在的beanDefinitionNames=======> + ");
		for (String name: applicationContext.getBeanDefinitionNames()) {
			System.out.println(name);
		}
		System.out.println("PostConstruct");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}
}
